package com.shanjupay.transaction.controller;

import com.shanjupay.common.domain.BusinessException;

import com.shanjupay.transaction.api.PayChannelService;
import com.shanjupay.transaction.api.dto.PayChannelDTO;
import com.shanjupay.transaction.api.dto.PayChannelParamDTO;
import com.shanjupay.transaction.api.dto.PlatformChannelDTO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 *
 * @Description
 * @Author zhangbing
 * @Date 2024/5/20 15:42
 **/
@RestController
public class PlatFormChannelController {

    @Autowired
    private PayChannelService payChannelService;

    @GetMapping("/PlatformChanList")
    List<PlatformChannelDTO> queryPlatformChannel()throws BusinessException{
        List<PlatformChannelDTO> list = payChannelService.queryPlatformChannel();
        return list;
    }

    //绑定服务类型
    @PostMapping("/apps/{appId}/platformChannel")
    void bindPlatformChannelForApp(@PathVariable String appId,@RequestParam String platformChannelCodes) throws BusinessException{
        payChannelService.bindPlatformChannelForApp(appId,platformChannelCodes);
    }

    //查看绑定状态
    @GetMapping("/merchant/apps/platformChannels")
    int queryAppBindPlatformChannel(@RequestParam String appId,@RequestParam String platformChannel) throws BusinessException{
        return payChannelService.queryAppBindPlatformChannel(appId,platformChannel);
    }
    //通过服务类型获取原始渠道列表
    @GetMapping("/payChannel/platformChannel/{platformChannelCode}")
    List<PayChannelDTO> queryPayChannelByPlatFormChannel(@PathVariable String platformChannelCode){
        return payChannelService.queryPayChannelByPlatFormChannel(platformChannelCode);
    }



    //保存支付渠道参数
    @PostMapping("/payChannelParams")
    public void savePayChannelParam(@RequestBody PayChannelParamDTO payChannelParamDTO){
        payChannelService.savePayChannelParam(payChannelParamDTO);
    }

    //根据应用和服务类型获取支付渠道参数列表
    @GetMapping("/payChannelParams/apps/{appId}/platformChannels/{platformChannel}")
    List<PayChannelParamDTO> queryPayChannelParambyAppIdPlatformChannel(@PathVariable String appId,@PathVariable String platformChannel){

        return payChannelService.queryPayChannelParambyAppIdPlatformChannel(appId,platformChannel);
    }

    //根据应用和服务类型和支付渠道获取单个支付渠道参数
    @GetMapping("/payChannelParams/apps/{appId}/platformChannels/{platformChannel}/payChannels/{payChannel}")
    PayChannelParamDTO queryParamByAppIdPlatformChannelAndpayChannel(@PathVariable String appId,@PathVariable String platformChannel,@PathVariable String payChannel){
        return payChannelService.queryParamByAppIdPlatformChannelAndpayChannel(appId, platformChannel, payChannel);
    }

}
